/*
 * @Autor: lh
 * @Date: 2023-10-09 13:37:49
 * @LastEditors: lh
 * @LastEditTime: 2024-03-05 17:30:48
 * @Description:
 */
import { request } from "@/utils/service"

/** 增 */
export function createTableDataApi(data: any, url?: string, isAddArr = true, headers?: any) {
  let params = {
    url: url,
    method: "post",
    data: isAddArr ? [data] : data
    // headers: {
    //   "Content-Type": "multipart/form-data"
    // }
  }
  if (headers) {
    params["headers"] = headers
  }
  return request(params)
}

/** 删 */
export function deleteTableDataApi(id: any, url?: string) {
  return request({
    url: url,
    method: "post",
    data: id
  })
}

/** 改 */
export function updateTableDataApi(data: any, url?: string) {
  return request({
    url: url,
    method: "post",
    data
  })
}

/** 查 */
export function getTableDataApi(data: any, url?: string) {
  return request({
    url: url,
    method: "post",
    data: data
  })
}

/** 批量删除 */
export function getTablePl(data: any, url?: string) {
  return request({
    url: url,
    method: "post",
    data
  })
}

/**表格导出*/
export function getTablecvg(params: any, url: string) {
  return request({
    url: url,
    method: "get",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    responseType: "blob",
    isCheck: true,
    params
  })
}

/**select 下拉框数据  */
export function getSelectList(params: any) {
  return request({
    url: "/auth/select",
    method: "post",
    params
  })
}

/** 上传文件 */
export function upLoadFile(data: any, url = "") {
  return request<any>({
    url: url,
    method: "post",
    data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  })
}
